
module.exports = class extends think.Model
{

    static get pk()
    {
        return 'PK_ApplicationGuid';
    }


    async addWorks(worksData,worksToStepsData){
        try{
            await this.startTrans();
            let stepworksModel=this.model('competitionsteptoworks').db(this.db());
            let worksModel=this.model('works').db(this.db());

            let b1=await worksModel.add(worksData);
            let b2=await  stepworksModel.add(worksToStepsData);
            if(b1===0&&b2===0){
                await this.commit();
                return {
                    errNo:0,
                    errMsg:'添加成功'
                }
            }else{
              await  this.rollback();
                return {
                    errNo:-1,
                    errMsg:"系统繁忙,请稍后再试"
                }

            }
        }catch(e){
          await  this.rollback();
            think.logger.warn(e);
            return {
                errNo:52041,
                errMsg:"上传作品时的cpstep不存在,请检查cpstep"
            }
        }



    }
};